package com.dailywork.basepro.stroper;

import com.common.comenum.EnumDirection;
import com.common.comenum.EnumSymbol;
import com.common.constants.Constants;
import com.common.constants.NumberConstants;
import com.util.CommonUtil;
import io.netty.util.internal.StringUtil;
import javafx.util.Pair;
import org.apache.commons.lang3.math.NumberUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 字符串数学表达式计算
 *
 * @author think
 * @version 2019/11/10
 */
public class ExpressParse {

    private static Logger logger = LoggerFactory.getLogger(ExpressParse.class);

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str = scanner.next();
        int len = str.length();
        while (!CommonUtil.isNumber(str)) {
            logger.info("the str is :" + str);
            if (str.contains(EnumOperation.MULTY.getSymbol())) {
                str = myltyOper(str);
            }
            if (str.contains(EnumOperation.DIV.getSymbol())) {
                str = divOper(str);
            }
            if (str.contains(EnumOperation.PLUS.getSymbol())) {
                str = addOper(str);
            }
            if (str.contains(EnumOperation.MINUS.getSymbol())) {
                str = minusOper(str);
            }
            if (len == str.length()) {
                break;
            }
        }
        System.out.println(str);
    }

    private static String minusOper(String express) {
        int index = 0;
        while ((index = express.indexOf(EnumOperation.MINUS.getSymbol(), index))
                != NumberConstants.NEG_ONE
                && express.charAt(index - 1) != EnumSymbol.LEFT_BLANK.getSymbol()
                && express.charAt(index + 1) != EnumSymbol.RIGHT_BLANK.getSymbol()) {
            if (express.charAt(index - 1) == EnumSymbol.RIGHT_BLANK.getSymbol()
                    || express.charAt(index + 1) == EnumSymbol.LEFT_BLANK.getSymbol()) {
                index = index + 1;
                continue;
            }
            String leftNum = findNumber(express.substring(0, index), EnumDirection.LEFT.getDir());
            String rightNum = findNumber(express.substring(index + 1), EnumDirection.RIGHT.getDir());
            String str =
                    String.valueOf(
                            EnumOperation.MINUS.apply(Integer.parseInt(leftNum), Integer.parseInt(rightNum)));
            int leftLen = leftNum.length();
            int rightLen = rightNum.length();
            int start = index - leftLen;
            int end = index + rightLen;
            // 如果计算结果之后两边都是括号，则删除括号
            if (express.charAt(start == NumberConstants.ZERO ? start : start - 1)
                    == EnumSymbol.LEFT_BLANK.getSymbol()
                    && express.charAt(end + 1) == EnumSymbol.RIGHT_BLANK.getSymbol()) {
                express = express.substring(0, start - 1) + str + express.substring(end + 2);
            } else {
                express = express.substring(0, start) + str + express.substring(end + 1);
            }
        }
        return express;
    }

    private static String addOper(String express) {
        int index = 0;
        while ((index = express.indexOf(EnumOperation.PLUS.getSymbol(), index))
                != NumberConstants.NEG_ONE
                && express.charAt(index - 1) != EnumSymbol.LEFT_BLANK.getSymbol()
                && express.charAt(index + 1) != EnumSymbol.RIGHT_BLANK.getSymbol()) {
            if (express.charAt(index - 1) == EnumSymbol.RIGHT_BLANK.getSymbol()
                    || express.charAt(index + 1) == EnumSymbol.LEFT_BLANK.getSymbol()) {
                index = index + 1;
                continue;
            }
            String leftNum = findNumber(express.substring(0, index), EnumDirection.LEFT.getDir());
            String rightNum = findNumber(express.substring(index + 1), EnumDirection.RIGHT.getDir());
            String str =
                    String.valueOf(
                            EnumOperation.PLUS.apply(Integer.parseInt(leftNum), Integer.parseInt(rightNum)));
            int leftLen = leftNum.length();
            int rightLen = rightNum.length();
            int start = index - leftLen;
            int end = index + rightLen;
            // 如果计算结果之后两边都是括号，则删除括号
            if (express.charAt(start == NumberConstants.ZERO ? start : start - 1)
                    == EnumSymbol.LEFT_BLANK.getSymbol()
                    && express.charAt(end + 1) == EnumSymbol.RIGHT_BLANK.getSymbol()) {
                express = express.substring(0, start - 1) + str + express.substring(end + 2);
            } else {
                express = express.substring(0, start) + str + express.substring(end + 1);
            }
        }
        return express;
    }

    private static String divOper(String express) {
        int index = 0;
        while ((index = express.indexOf(EnumOperation.DIV.getSymbol(), index))
                != NumberConstants.NEG_ONE
                && express.charAt(index - 1) != EnumSymbol.LEFT_BLANK.getSymbol()
                && express.charAt(index + 1) != EnumSymbol.RIGHT_BLANK.getSymbol()) {

            if (express.charAt(index - 1) == EnumSymbol.RIGHT_BLANK.getSymbol()) {
                String rightNum = findNumber(express.substring(index + 1), EnumDirection.RIGHT.getDir());
                if (express.charAt(index + rightNum.length() + 1) != EnumSymbol.RIGHT_BLANK.getSymbol()) {
                    Pair<Integer, Integer> pair =
                            indexOfBlank(express.substring(0, index), EnumDirection.LEFT.getDir());
                    int left = pair.getKey();
                    express =
                            express.substring(0, left)
                                    + EnumSymbol.LEFT_BLANK.getSymbol()
                                    + express.substring(left, rightNum.length() + index + 1)
                                    + EnumSymbol.RIGHT_BLANK.getSymbol()
                                    + express.substring(rightNum.length() + index + 1);
                }
                index = index + 1;
                continue;
            }

            if (express.charAt(index + 1) == EnumSymbol.LEFT_BLANK.getSymbol()) {
                String leftNum = findNumber(express.substring(0, index), EnumDirection.LEFT.getDir());
                if (express.charAt(index - leftNum.length() - 1) != EnumSymbol.LEFT_BLANK.getSymbol()) {
                    Pair<Integer, Integer> pair =
                            indexOfBlank(express.substring(index + 1), EnumDirection.RIGHT.getDir());
                    int right = pair.getValue();
                    express =
                            express.substring(0, index - leftNum.length())
                                    + EnumSymbol.LEFT_BLANK.getSymbol()
                                    + express.substring(index - leftNum.length(), index + right + 2)
                                    + EnumSymbol.RIGHT_BLANK.getSymbol()
                                    + express.substring(index + right + 2);
                }
                index = index + 1;
                continue;
            }

            String leftNum = findNumber(express.substring(0, index), EnumDirection.LEFT.getDir());
            String rightNum = findNumber(express.substring(index + 1), EnumDirection.RIGHT.getDir());
            String str =
                    String.valueOf(
                            EnumOperation.DIV.apply(Integer.parseInt(leftNum), Integer.parseInt(rightNum)));
            int leftLen = leftNum.length();
            int rightLen = rightNum.length();
            int start = index - leftLen;
            int end = index + rightLen;
            // 如果计算结果之后两边都是括号，则删除括号
            if (express.charAt(start - 1) == EnumSymbol.LEFT_BLANK.getSymbol()
                    && express.charAt(end + 1) == EnumSymbol.RIGHT_BLANK.getSymbol()) {
                express = express.substring(0, start - 1) + str + express.substring(end + 2);
            } else {
                express = express.substring(0, start) + str + express.substring(end + 1);
            }
        }
        return express;
    }

    /**
     * 乘法运算操作
     *
     * @param express 字符串表达式
     * @return 识别乘法运算之后做乘法运算得到结果替换之后的字符串
     */
    private static String myltyOper(String express) {
        int index = 0;
        while ((index = express.indexOf(EnumOperation.MULTY.getSymbol(), index))
                != NumberConstants.NEG_ONE
                && express.charAt(index - 1) != EnumSymbol.LEFT_BLANK.getSymbol()
                && express.charAt(index + 1) != EnumSymbol.RIGHT_BLANK.getSymbol()) {
            if (express.charAt(index - 1) == EnumSymbol.RIGHT_BLANK.getSymbol()) {
                String rightNum = findNumber(express.substring(index + 1), EnumDirection.RIGHT.getDir());
                if (express.charAt(index + rightNum.length() + 1) != EnumSymbol.RIGHT_BLANK.getSymbol()) {
                    Pair<Integer, Integer> pair =
                            indexOfBlank(express.substring(0, index), EnumDirection.LEFT.getDir());
                    int left = pair.getKey();
                    express =
                            express.substring(0, left)
                                    + EnumSymbol.LEFT_BLANK.getSymbol()
                                    + express.substring(left, rightNum.length() + index + 1)
                                    + EnumSymbol.RIGHT_BLANK.getSymbol()
                                    + express.substring(rightNum.length() + index + 1);
                }
                index = index + 1;
                continue;
            }

            if (express.charAt(index + 1) == EnumSymbol.LEFT_BLANK.getSymbol()) {
                String leftNum = findNumber(express.substring(0, index), EnumDirection.LEFT.getDir());
                if (express.charAt(index - leftNum.length() - 1) != EnumSymbol.LEFT_BLANK.getSymbol()) {
                    Pair<Integer, Integer> pair =
                            indexOfBlank(express.substring(index + 1), EnumDirection.RIGHT.getDir());
                    int right = pair.getValue();
                    express =
                            express.substring(0, index - leftNum.length())
                                    + EnumSymbol.LEFT_BLANK.getSymbol()
                                    + express.substring(index - leftNum.length(), index + right + 2)
                                    + EnumSymbol.RIGHT_BLANK.getSymbol()
                                    + express.substring(index + right + 2);
                }
                index = index + 1;
                continue;
            }
            String leftNum = findNumber(express.substring(0, index), EnumDirection.LEFT.getDir());
            String rightNum = findNumber(express.substring(index + 1), EnumDirection.RIGHT.getDir());
            String str =
                    String.valueOf(
                            EnumOperation.MULTY.apply(Integer.parseInt(leftNum), Integer.parseInt(rightNum)));
            int leftLen = leftNum.length();
            int rightLen = rightNum.length();
            int start = index - leftLen;
            int end = index + rightLen;
            // 如果计算结果之后两边都是括号，则删除括号
            if (express.charAt(start - 1) == EnumSymbol.LEFT_BLANK.getSymbol()
                    && express.charAt(end + 1) == EnumSymbol.RIGHT_BLANK.getSymbol()) {
                express = express.substring(0, start - 1) + str + express.substring(end + 2);
            } else {
                express = express.substring(0, start) + str + express.substring(end + 1);
            }
        }
        return express;
    }

    private static String modOper(String express) {
        int index = 0;
        while ((index = express.indexOf(EnumOperation.MODE.getSymbol(), index))
                != NumberConstants.NEG_ONE
                && express.charAt(index - 1) != EnumSymbol.LEFT_BLANK.getSymbol()
                && express.charAt(index + 1) != EnumSymbol.RIGHT_BLANK.getSymbol()) {
            if (express.charAt(index - 1) == EnumSymbol.RIGHT_BLANK.getSymbol()) {
                String rightNum = findNumber(express.substring(index + 1), EnumDirection.RIGHT.getDir());
                if (express.charAt(index + rightNum.length() + 1) != EnumSymbol.RIGHT_BLANK.getSymbol()) {
                    Pair<Integer, Integer> pair =
                            indexOfBlank(express.substring(0, index), EnumDirection.LEFT.getDir());
                    int left = pair.getKey();
                    express =
                            express.substring(0, left)
                                    + EnumSymbol.LEFT_BLANK.getSymbol()
                                    + express.substring(left, rightNum.length() + index + 1)
                                    + EnumSymbol.RIGHT_BLANK.getSymbol()
                                    + express.substring(rightNum.length() + index + 1);
                }
                index = index + 1;
                continue;
            }

            if (express.charAt(index + 1) == EnumSymbol.LEFT_BLANK.getSymbol()) {
                String leftNum = findNumber(express.substring(0, index), EnumDirection.LEFT.getDir());
                if (express.charAt(index - leftNum.length() - 1) != EnumSymbol.LEFT_BLANK.getSymbol()) {
                    Pair<Integer, Integer> pair =
                            indexOfBlank(express.substring(index + 1), EnumDirection.RIGHT.getDir());
                    int right = pair.getValue();
                    express =
                            express.substring(0, index - leftNum.length())
                                    + EnumSymbol.LEFT_BLANK.getSymbol()
                                    + express.substring(index - leftNum.length(), index + right + 2)
                                    + EnumSymbol.RIGHT_BLANK.getSymbol()
                                    + express.substring(index + right + 2);
                }
                index = index + 1;
                continue;
            }
            String leftNum = findNumber(express.substring(0, index), EnumDirection.LEFT.getDir());
            String rightNum = findNumber(express.substring(index + 1), EnumDirection.RIGHT.getDir());
            String str =
                    String.valueOf(
                            EnumOperation.MODE.apply(Integer.parseInt(leftNum), Integer.parseInt(rightNum)));
            int leftLen = leftNum.length();
            int rightLen = rightNum.length();
            int start = index - leftLen;
            int end = index + rightLen;
            // 如果计算结果之后两边都是括号，则删除括号
            if (express.charAt(start - 1) == EnumSymbol.LEFT_BLANK.getSymbol()
                    && express.charAt(end + 1) == EnumSymbol.RIGHT_BLANK.getSymbol()) {
                express = express.substring(0, start - 1) + str + express.substring(end + 2);
            } else {
                express = express.substring(0, start) + str + express.substring(end + 1);
            }
        }
        return express;
    }

    private static String minOper(String express) {
        int index = 0;
        while ((index = express.indexOf(EnumOperation.MIN.getSymbol(), index))
                != NumberConstants.NEG_ONE
                && express.charAt(index - 1) != EnumSymbol.LEFT_BLANK.getSymbol()
                && express.charAt(index + 1) != EnumSymbol.RIGHT_BLANK.getSymbol()) {
            if (express.charAt(index - 1) == EnumSymbol.RIGHT_BLANK.getSymbol()) {
                String rightNum = findNumber(express.substring(index + 1), EnumDirection.RIGHT.getDir());
                if (express.charAt(index + rightNum.length() + 1) != EnumSymbol.RIGHT_BLANK.getSymbol()) {
                    Pair<Integer, Integer> pair =
                            indexOfBlank(express.substring(0, index), EnumDirection.LEFT.getDir());
                    int left = pair.getKey();
                    express =
                            express.substring(0, left)
                                    + EnumSymbol.LEFT_BLANK.getSymbol()
                                    + express.substring(left, rightNum.length() + index + 1)
                                    + EnumSymbol.RIGHT_BLANK.getSymbol()
                                    + express.substring(rightNum.length() + index + 1);
                }
                index = index + 1;
                continue;
            }

            if (express.charAt(index + 1) == EnumSymbol.LEFT_BLANK.getSymbol()) {
                String leftNum = findNumber(express.substring(0, index), EnumDirection.LEFT.getDir());
                if (express.charAt(index - leftNum.length() - 1) != EnumSymbol.LEFT_BLANK.getSymbol()) {
                    Pair<Integer, Integer> pair =
                            indexOfBlank(express.substring(index + 1), EnumDirection.RIGHT.getDir());
                    int right = pair.getValue();
                    express =
                            express.substring(0, index - leftNum.length())
                                    + EnumSymbol.LEFT_BLANK.getSymbol()
                                    + express.substring(index - leftNum.length(), index + right + 2)
                                    + EnumSymbol.RIGHT_BLANK.getSymbol()
                                    + express.substring(index + right + 2);
                }
                index = index + 1;
                continue;
            }
            String leftNum = findNumber(express.substring(0, index), EnumDirection.LEFT.getDir());
            String rightNum = findNumber(express.substring(index + 1), EnumDirection.RIGHT.getDir());
            String str =
                    String.valueOf(
                            EnumOperation.MIN.apply(Integer.parseInt(leftNum), Integer.parseInt(rightNum)));
            int leftLen = leftNum.length();
            int rightLen = rightNum.length();
            int start = index - leftLen;
            int end = index + rightLen;
            // 如果计算结果之后两边都是括号，则删除括号
            if (express.charAt(start - 1) == EnumSymbol.LEFT_BLANK.getSymbol()
                    && express.charAt(end + 1) == EnumSymbol.RIGHT_BLANK.getSymbol()) {
                express = express.substring(0, start - 1) + str + express.substring(end + 2);
            } else {
                express = express.substring(0, start) + str + express.substring(end + 1);
            }
        }
        return express;
    }

    private static String maxOper(String express) {
        int index = 0;
        while ((index = express.indexOf(EnumOperation.MAX.getSymbol(), index))
                != NumberConstants.NEG_ONE
                && express.charAt(index - 1) != EnumSymbol.LEFT_BLANK.getSymbol()
                && express.charAt(index + 1) != EnumSymbol.RIGHT_BLANK.getSymbol()) {
            if (express.charAt(index - 1) == EnumSymbol.RIGHT_BLANK.getSymbol()) {
                String rightNum = findNumber(express.substring(index + 1), EnumDirection.RIGHT.getDir());
                if (express.charAt(index + rightNum.length() + 1) != EnumSymbol.RIGHT_BLANK.getSymbol()) {
                    Pair<Integer, Integer> pair =
                            indexOfBlank(express.substring(0, index), EnumDirection.LEFT.getDir());
                    int left = pair.getKey();
                    express =
                            express.substring(0, left)
                                    + EnumSymbol.LEFT_BLANK.getSymbol()
                                    + express.substring(left, rightNum.length() + index + 1)
                                    + EnumSymbol.RIGHT_BLANK.getSymbol()
                                    + express.substring(rightNum.length() + index + 1);
                }
                index = index + 1;
                continue;
            }

            if (express.charAt(index + 1) == EnumSymbol.LEFT_BLANK.getSymbol()) {
                String leftNum = findNumber(express.substring(0, index), EnumDirection.LEFT.getDir());
                if (express.charAt(index - leftNum.length() - 1) != EnumSymbol.LEFT_BLANK.getSymbol()) {
                    Pair<Integer, Integer> pair =
                            indexOfBlank(express.substring(index + 1), EnumDirection.RIGHT.getDir());
                    int right = pair.getValue();
                    express =
                            express.substring(0, index - leftNum.length())
                                    + EnumSymbol.LEFT_BLANK.getSymbol()
                                    + express.substring(index - leftNum.length(), index + right + 2)
                                    + EnumSymbol.RIGHT_BLANK.getSymbol()
                                    + express.substring(index + right + 2);
                }
                index = index + 1;
                continue;
            }
            String leftNum = findNumber(express.substring(0, index), EnumDirection.LEFT.getDir());
            String rightNum = findNumber(express.substring(index + 1), EnumDirection.RIGHT.getDir());
            String str =
                    String.valueOf(
                            EnumOperation.MAX.apply(Integer.parseInt(leftNum), Integer.parseInt(rightNum)));
            int leftLen = leftNum.length();
            int rightLen = rightNum.length();
            int start = index - leftLen;
            int end = index + rightLen;
            // 如果计算结果之后两边都是括号，则删除括号
            if (express.charAt(start - 1) == EnumSymbol.LEFT_BLANK.getSymbol()
                    && express.charAt(end + 1) == EnumSymbol.RIGHT_BLANK.getSymbol()) {
                express = express.substring(0, start - 1) + str + express.substring(end + 2);
            } else {
                express = express.substring(0, start) + str + express.substring(end + 1);
            }
        }
        return express;
    }

    /**
     * 按照方向顺序查找数字
     *
     * @param str 字符串
     * @return 数字字符串
     */
    private static String findNumber(String str, String dir) {
        String result = StringUtil.EMPTY_STRING;
        if (dir.equalsIgnoreCase(EnumDirection.LEFT.getDir())) {
            result = findLastGroup(str);
        } else if (dir.equalsIgnoreCase(EnumDirection.RIGHT.getDir())) {
            result = findFirstGroup(str);
        } else {
            logger.info("Dir is error!");
        }
        return result;
    }

    /**
     * 查找所有字符所在的字符串中的位置
     *
     * @param str    字符串
     * @param target 字符串
     * @return 所在位置的数组
     */
    private static List<Integer> findCharInStr(String str, String target) {
        int index = 0;
        List<Integer> indexs = new ArrayList<>();
        while ((index = str.indexOf(target, index)) != -1) {
            indexs.add(index);
            index = index + 1;
        }
        return indexs;
    }

    private static String findLastGroup(String str) {
        Pattern pattern = Pattern.compile(Constants.NUM_STR2);
        Matcher matcher = pattern.matcher(str);
        String result = StringUtil.EMPTY_STRING;
        while (matcher.find()) {
            result = matcher.group(1);
        }
        int index = str.length() - result.length();
        if (index > NumberConstants.ONE
                && str.charAt(index - NumberConstants.ONE) == '-'
                && !NumberUtils.isDigits(String.valueOf(str.charAt(index - NumberConstants.TWO)))) {
            result = "-" + matcher.group(NumberConstants.ONE);
        }
        return result;
    }

    private static String findFirstGroup(String str) {
        Pattern pattern = Pattern.compile(Constants.NUM_STR2);
        Matcher matcher = pattern.matcher(str);
        String result = StringUtil.EMPTY_STRING;
        if (matcher.find()) {
            result = matcher.group(1);
        }
        if (str.charAt(NumberConstants.ZERO) == '-') {
            result = "-" + matcher.group(NumberConstants.ONE);
        }
        return result;
    }

    /**
     * 查找匹配的同等级的括号的序号
     *
     * @param str 字符串
     * @return 对等的括号的位置
     */
    private static Pair<Integer, Integer> indexOfBlank(String str, String dir) {
        List<Integer> leftStack = new ArrayList<>();
        List<Integer> rightStack = new ArrayList<>();
        // 作为标记
        int core = -1;
        // 从右往左
        int index = str.length();
        if (dir.equalsIgnoreCase(EnumDirection.LEFT.getDir())) {
            while ((index = str.lastIndexOf(EnumSymbol.LEFT_BLANK.getSymbol(), index))
                    != NumberConstants.NEG_ONE) {
                leftStack.add(index);
                index = index - 1;
            }
            index = str.length();
            while ((index = str.lastIndexOf(EnumSymbol.RIGHT_BLANK.getSymbol(), index))
                    != NumberConstants.NEG_ONE) {
                if (core == -1) {
                    core = index;
                }
                rightStack.add(index);
                index = index - 1;
            }
        }

        // 从左往右
        if (dir.equalsIgnoreCase(EnumDirection.RIGHT.getDir())) {
            index = 0;
            while ((index = str.indexOf(EnumSymbol.LEFT_BLANK.getSymbol(), index))
                    != NumberConstants.NEG_ONE) {
                if (core == -1) {
                    core = index;
                }
                leftStack.add(index);
                index = index + 1;
            }
            index = 0;
            while ((index = str.indexOf(EnumSymbol.RIGHT_BLANK.getSymbol(), index))
                    != NumberConstants.NEG_ONE) {
                rightStack.add(index);
                index = index + 1;
            }
        }

        // 寻找匹配的括号编号
        List<Pair<Integer, Integer>> result = new ArrayList<>();
        List<Integer> temp = new ArrayList<>();
        Pair<Integer, Integer> pair2 = new Pair<>(-1, -1);
        int lenRight = rightStack.size();
        if (lenRight == 1) {
            pair2 = new Pair<>(leftStack.get(0), rightStack.get(0));
        } else {
            for (Integer right : rightStack) {
                int len = leftStack.size();
                if (len == 1) {
                    pair2 = new Pair<>(leftStack.get(0), right);
                    break;
                }
                if (leftStack.get(len - 1) < right) {
                    pair2 = new Pair<>(leftStack.get(len - 1), right);
                    break;
                }

                for (int i = 0; i < len; i++) {
                    if (leftStack.get(i) > right) {
                        if (!temp.contains(leftStack.get(i - 1))) {
                            Pair<Integer, Integer> pair = new Pair<>(leftStack.get(i - 1), right);
                            temp.add(leftStack.get(i - 1));
                            temp.add(right);
                            result.add(pair);
                        } else {
                            Pair<Integer, Integer> pair = new Pair<>(leftStack.get(i - temp.size() - 1), right);
                            temp.add(leftStack.get(i - temp.size() - 1));
                            temp.add(right);
                            result.add(pair);
                        }
                        break;
                    }
                }
            }
        }
        for (Pair<Integer, Integer> pair1 : result) {
            if (pair1.getKey().equals(core)) {
                pair2 = pair1;
            }
        }
        return pair2;
    }

    public static void regexTest() {
        String text =
                "John writes about this, and John writes about that,"
                        + " and John writes about everything. ";
        String patternString1 = "(John)";
        Pattern pattern = Pattern.compile(patternString1);
        Matcher matcher = pattern.matcher(text);
        System.out.println("groupCount is -->" + matcher.groupCount());
        while (matcher.find()) {
            System.out.println("found: " + matcher.group(1));
        }
    }
}
